//package com.qingfeng.client;
//
//import com.qingfeng.client.bean.Buyer;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.annotation.WebListener;
//import javax.servlet.http.HttpSessionAttributeListener;
//import javax.servlet.http.HttpSessionBindingEvent;
//import javax.servlet.http.HttpSessionEvent;
//import javax.servlet.http.HttpSessionListener;
//
///**
// * @author zhangyuefei
// * @version 1.0
// * @date 2020/4/16 2:01 下午
// */
//@Slf4j
//@Component
//public class MySessionListener implements HttpSessionListener, HttpSessionAttributeListener {
//
//    public static int online = 0;
//
//    public static int loginNum=0;
//
//    @Override
//    public void sessionCreated(HttpSessionEvent se) {
//        online++;
//        log.info("session create online people "+online);
//    }
//
//    @Override
//    public void sessionDestroyed(HttpSessionEvent se) {
//        online--;
//        log.info("session destory online people "+online);
//    }
//
//
////    HttpSessionAttributeListener 接口实现方法，用于监听session中对象的变化
//
//    @Override
//    public void attributeAdded(HttpSessionBindingEvent se) {
//        Buyer buyer =  (Buyer) se.getSession().getAttribute("buyerBean");
//        if (buyer!=null){
//            loginNum++;
//        }
//    }
//
//    @Override
//    public void attributeRemoved(HttpSessionBindingEvent se) {
//        Buyer buyer =  (Buyer) se.getSession().getAttribute("buyerBean");
//        if (buyer==null){
//            loginNum--;
//        }
//    }
//}
